<?php
$paginator->options(array('url' => $this->passedArgs));

if(!isset($nocoach))
    $nocoach = false;

if(!isset($isUnique))
    $isUnique = false;

    if($isUnique){
        $coaches = array(0 => $coaches);
    }
?>
<div id="elt_coaches_totalstats" id="stats">
    <h3><?php echo $title;?></h3>
    <p><?php if(!$isUnique){echo $paginator->counter(array('format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true))); }?></p>
    <?php if (!empty($coaches)):?>
    <table cellpadding = "0" cellspacing = "0">
    <tr>
<?php if(!$nocoach) {?><th><?php echo $paginator->sort(__('Coach',true), 'Coach.coach_id');?></th><?php }?>
        <th><?php echo $paginator->sort(__('G',true), 'CoachTotalStatistic.iMatchPlayed', array('url'=> array('direction' => 'desc')));?></th>
        <th><?php echo $paginator->sort(__('W',true), 'CoachTotalStatistic.iWins', array('url'=> array('direction' => 'desc')));?></th>
        <th><?php echo $paginator->sort(__('D',true), 'CoachTotalStatistic.iDraws', array('url'=> array('direction' => 'desc')));?></th>
        <th><?php echo $paginator->sort(__('L',true), 'CoachTotalStatistic.iLoss', array('url'=> array('direction' => 'desc')));?></th>
        <th><?php echo $paginator->sort(__('%W',true), 'CoachTotalStatistic.fPercentageWins', array('url'=> array('direction' => 'desc')));?></th>
        <th><?php echo $paginator->sort(__('%D',true), 'CoachTotalStatistic.fPercentageDraws', array('url'=> array('direction' => 'desc')));?></th>
        <th><?php echo $paginator->sort(__('%L',true), 'CoachTotalStatistic.fPercentageLoss', array('url'=> array('direction' => 'desc')));?></th>
<?php if(!$noaction) {?><th class="actions"><?php __('Actions');?></th><?php }?>
    </tr>
    <?php
        $i = 0;
        foreach ($coaches as $coach):
            $class = null;
            if ($i++ % 2 == 0) {
                $class = ' class="altrow"';
            }
        ?>
        <tr<?php echo $class;?>>
<?php if(!$nocoach) {?><td><?php echo $html->link($coach['Coach']['strName'], array('controller' => 'coaches', 'action' => 'view', $coach['Coach']['id'])); ?></td><?php }?>
            <td><?php echo $coach['CoachTotalStatistic']['iMatchPlayed'];?></td>
            <td><?php echo $coach['CoachTotalStatistic']['iWins'];?></td>
            <td><?php echo $coach['CoachTotalStatistic']['iDraws'];?></td>
            <td><?php echo $coach['CoachTotalStatistic']['iLoss'];?></td>
            <td><?php echo $number->toPercentage($coach['CoachTotalStatistic']['fPercentageWins'], 1); ?></td>
            <td><?php echo $number->toPercentage($coach['CoachTotalStatistic']['fPercentageDraws'], 1); ?></td>
            <td><?php echo $number->toPercentage($coach['CoachTotalStatistic']['fPercentageLoss'], 1); ?> </td>
<?php if(!$noaction) {?><td class="actions">
                <?php echo $html->link(__('View', true), array('controller' => 'Coachs', 'action' => 'view', $coach['Coach']['id'])); ?>
                <?php echo $html->link(__('Edit', true), array('controller' => 'Coachs', 'action' => 'edit', $coach['Coach']['id'])); ?>
                <?php echo $html->link(__('Delete', true), array('controller' => 'Coachs', 'action' => 'delete', $coach['Coach']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $coach['Coach']['id'])); ?>
            </td><?php }?>
        </tr>
    <?php endforeach; ?>
    </table>
<?php endif; ?>
</div>
<div class="paging">
    <?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
 |  <?php echo $paginator->numbers();?>
    <?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
</div>